﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using WebCore.Models.DataEntities;

namespace WebCore.Models.DataManagers
{
    public enum SettingGroupEnum
    {        
        TransportPolicy,
        PaymentPolicy,
        RefundPolicy,
        CustomerEvent,
        UserAgreement,
        UserPrivacy,
        NewBestAvatar,                
        ProductAvatar,
        ProductReviewAvatar,
        ReviewHistoryAvatar,
        CustomerCenterAvatar
    }
    

    public class SettingManager
    {
        public static List<Setting> GetActiveSettings(SettingGroupEnum groupEnum, string lang)
        {
            DataEntities.DataEntities entities = new DataEntities.DataEntities();
            return (from d in entities.Settings
                    where d.Group == groupEnum.ToString() && d.Lang == lang
                    orderby d.OrderNumber ascending
                    select d).ToList();
        }

        public static Setting GetSetting(Guid settingID)
        {
            DataEntities.DataEntities entities = new DataEntities.DataEntities();
            return (from d in entities.Settings
                    where d.SettingID == settingID                    
                    select d).FirstOrDefault();
        }
    }
}